package com.myebills.ebpsfrontend.cust.maxis;

import java.sql.*;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.myebills.ebpsfrontend.cust.controller.*;
import javax.servlet.http.HttpSession;
import com.ibm.logging.ILogger;
import com.ibm.logging.IRecordType;

public class CusPhoneBookUpdateAllServlet_v1r00 extends EbppxTransactionServlet {

private final String addErrorMsg = "Contact with same phone number already existed in phonebook";
static int count = 0;
    public void doTransaction(HttpServletRequest req, HttpServletResponse res) throws ServletException {
        try {
        ILogger trcLogger = null;
        trcLogger = getTraceLogger(req);
        final String fName = "doTransaction";
        if (trcLogger.isLogging())
            trcLogger.entry(IRecordType.TYPE_INFO, this, fName);

        final HttpSession session = req.getSession(false);
        if (null == session)
                throw new IllegalStateException("no session established");

        //Get attribute from session for the logon user
        final EbppxEcsUser ecsUser = (EbppxEcsUser) session.getAttribute(EbppxConstants.ECS_USER);

        doList(req, res, ecsUser);

        forwardToMappedUrl(req, res, EbppxConstants.URL_JSP_PARAM);
        }catch (Throwable t){
                throw new ServletException(t.toString(), t);
        }finally {
	} //finally

    }//doTransaction

    public void doList(HttpServletRequest req, HttpServletResponse res, EbppxEcsUser ecsUser) throws ServletException {
        try {
                Collection resultList = null;

                String[] numbers = req.getParameterValues("deleteBox");
                resultList = PhoneBookDAO.getInstance().list(ecsUser.getUserId(),numbers);
                req.setAttribute("PhoneBookList", resultList);

            }catch (Throwable t){
                throw new ServletException(t.toString(), t);
            }finally {
	    } //finally
    }

}
